# -*-coding:utf-8 -*-
# __author__=LuLu
from selenium.webdriver.common.by import By

from comment.Tools import sleep


class TourGuideDestinationLoc(object):
    """按钮"""
    add_button = (By.XPATH, '//*[@id="etravel"]/div/div[3]/div/div[1]/div/button[1]')  # 新增按钮
    choice_delete_button = (By.XPATH, '//*[@id="etravel"]/div/div[3]/div/div[1]/div/button[2]')  # 多选删除按钮

    """表格"""
    # 整个html-body
    destination_body = (By.XPATH, '/html/body')

    # 表格body
    destination_list_table = (By.XPATH, '//*[@id="etravel"]/div/div[3]/div/div[3]/div/div[1]/div[2]/div[2]/table/tbody')

    # 全选 --公共函数--selectBoxLocators-->select_all
    # 单选 --公共函数--selectBoxLocators-->select_one_box

    # 指定整行
    def one_rows(self):
        return By.XPATH, f'//*[@id="etravel"]/div/div[3]/div/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr[{self}]'

    # 指定行编辑按钮
    def edit_one_button(self):
        return By.XPATH, f'//*[@id="etravel"]/div/div[3]' \
                         f'/div/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr[{self}]/td[7]/a[1]'

    # 指定行删除按钮
    def delete_one_button(self):
        return By.XPATH, f'//*[@id="etravel"]/div/div[3]' \
                         f'/div/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr[{self}]/td[7]/a[2]'

    # 删除确认
    delete_yes = (By.XPATH, '//*[starts-with(@id,"Modalx")]/div/div/div/div[2]/button[2]')

    # 删除取消
    delete_no = (By.XPATH, '//*[starts-with(@id,"Modalx")]/div/div/div/div[2]/button[1]')
    # toast提醒
    toast_warn = (By.XPATH, '//*[@id="msgcontainer-toast"]')
    """新增编辑框"""
    destination_win = (By.XPATH, '//*[@id="modal-container"]')
    destination_title = (By.XPATH, '//*[@id="modal-item"]/div/div[1]')  # 弹层title
    destination_name = (By.XPATH, '//*[@id="destinationName"]')  # 目的地名称
    destination_length_limits = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[1]/div[2]/span[2]/p')  # 目的地长度限制

    destination_sorted = (By.XPATH, '//*[@id="sortIndex"]')  # 排序
    question_mark = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[2]/div[1]/span[2]/div/div')  # 排序问号
    question_mark_content = (
        By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[2]/div[1]/span[2]/div/div/div')  # 排序问号提示语

    destination_Logo_button = (By.XPATH, '//*[@id="destinationLogo"]/div/div/ul/li[2]/div')  # 目的地Logo
    destination_Logo_upload_success = (
        By.XPATH, '//*[@id="destinationLogo"]/div/div/ul/li/div[1]/div/div/img')  # 目的地Logo成功回显
    close_logo_button = (By.XPATH, '//*[@id="destinationLogo"]/div/div/ul/li[1]/div[1]/div/a')  # 删除logo按钮
    # 上传大小提醒
    upload_warn = (By.XPATH, '//*[@id="msgcontainer"]')
    """
    @动态变量处理为采用 starts-with 方式
    1.starts-with()  属性内容以什么为开头
    2.contains()   属性内容包含
    3.ends-with()   属性内容以什么结尾 
    """
    poi_edit_box = (By.XPATH, '//*[starts-with(@id,"dropdown")]/div[1]/div')  # poi已选择列表
    poi_edit_input = (By.XPATH, '//*[starts-with(@id,"dropdown")]/div[1]/input')  # poi输入框
    poi_edit_select_box = (By.XPATH, '//*[starts-with(@id,"dropdown")]/div[2]/div')  # 下拉列表

    # 选择一个poi
    def poi_edit_select_one(self, sleep_time=1):
        sleep(sleep_time)
        return By.XPATH, f'//*[starts-with(@id,"dropdown")]/div[2]/div/div[{self}]'  # 单个下拉选项

    # 删除一个poi
    def poi_edit_delete_one(self, sleep_time=1):
        sleep(sleep_time)
        return By.XPATH, f'//*[starts-with(@id,"dropdown")]/div[1]/div/span[{self}]/i'  # 删除单个选项

    commit_button = (By.XPATH, '//*[@id="modal-item"]/div/div[3]/a[2]')  # 确定按钮
    cancel_button = (By.XPATH, '//*[@id="modal-item"]/div/div[3]/a[1]')  # 取消按钮
    close_laye = (By.XPATH, '//*[@id="modal-item"]/div/div[1]/i')  # 关闭弹层

    """新增编辑异常提示框"""
    destination_name_warn = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[1]/div[2]/span[1]')
    destination_sorted_warn = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[2]/div[2]/span')
    destination_POI_warn = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[3]/div[2]/span[2]')
    destination_LOGO_warn = (By.XPATH, '//*[@id="modal-item"]/div/div[2]/div/lable[4]/div[2]/span[2]')

    '''翻页控件'''
    PageNum = (By.XPATH, '//*[@id="etravel"]/div/div[3]/div/div[3]/div/div[1]/div[3]/div[1]/span[1]')
    PageTurn = (By.XPATH, '//*[@id="etravel"]/div/div[3]/div/div[3]/div/div[1]/div[3]/div[2]/ul')
